'''###########################################################################################################################
### File: add_animations_gui.py
### Name: Patrick Delaney, Andrew Oberlin
### Class: CSE 487
### Instructor: Dr.Zmuda
### Assignment: Final Project
### Description: GUI for adding animations
################ 
'''
from panda3d.core import Vec2, Point3, Vec3, Vec4
from direct.gui.DirectGui import *
from pandac.PandaModules import TextNode
from menu_button import MenuButton
from Tkinter import Tk
from tkFileDialog import askopenfilename
from panda3d.core import Filename
from menu_scroller import MenuScroller
from animation import Animation
from animation_gen import AnimationGen

class AddAnimationsGUI:
	'''
	### Name: __init__ (Constructor)
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: Starts the process of creating a main character
	'''	
	def __init__(self, parent, charGen, mainCharacter):
		self.parent = parent
		self.characterGen = charGen
		self.mainCharacter = mainCharacter
		self.textureFile = ""
		self.animationGUI = None
		self.models = dict()
		self.__loadModels()
	
	'''
	### Name: __loadModels
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: Loads the models for the GUI
	'''	
	def __loadModels(self):
		numItemsVisible = 4
		itemHeight = 0.11
		self.models['animations_list'] = MenuScroller(
		    self.parent, 'animations_scroller', None, None, (0.0, 0.7, -0.05, 0.59), (-0.35, 0, -0.5), 
			numItemsVisible, itemHeight, (-0.2, 0.2, -0.37, 0.11), (0.35, 0, 0.4), self.onClick
		)
		
		self.models['new_animation_button'] = MenuButton(
			self.parent, 'new_animation_button', 'models/gui/game_maker/dialog_button', 
			self.addAnimation, Vec3(0, 0, 0.25), isMovie = False, text="New Animation", 
			textPos=Vec3(-0.35, 0, -0.015), scale=Vec3(0.8,1,0.2)
		)
		
	'''
	### Name: hide
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: hides this GUI
	'''
	def hide(self):
		for key in self.models.keys():
			self.models[key].hide()
			
	'''
	### Name: show
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: show this GUI
	'''
	def show(self):
		for key in self.models.keys():
			self.models[key].show()
	
	'''
	### Name: onClick
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: click event for an animation button
	'''
	def onClick(self, item, dir):
		print "click"
		
	'''
	### Name: addAnimation
	### Author: Andrew Oberlin, Patrick Delaney
	### Parameters: None
	### Description: adds a new animation
	'''
	def addAnimation(self):
		animation = Animation()
		self.hide()
		self.animationGUI = AnimationGen(self.parent, self.characterGen.project, animation, self.mainCharacter)